<template>
    <div>
      <form action="">
        <input type="text" v-model="name">用户名
        <input type="text" v-model="password">密码
        <button @click="on_login">登录</button>
      </form>
    </div>
</template>

<script>
    import axios from 'axios'
    export default {
        name: "login",
        data(){
          return{
            name:'',
            password:''
          }
        },
        methods: {
          on_login() {
            let form_data = new FormData();
            form_data.append('name', this.name);
            form_data.append('password', this.password);
            axios({
              method: 'POST',
              url: 'http://127.0.0.1:8000/login/',
              data: form_data

            }).then(res => {
              console.log(res)
              localStorage.setItem('name',this.name)
              this.$router.push({path:'/good',query:{'name':this.name}})
            })

          }
        }

    }
</script>

<style scoped>

</style>
